/**
 * Craeted with IntelliJ IDEA.
 * Description:
 * User:23687
 * Date:2024-09-26
 * Time:10:28
 */
import java.util.Scanner;

public class TestDemo {  public static int Add(int a,int b){
    return a+b;
}
    public static double Add(double a,double b,double c){
        return a+b+c;
    }
   /* public static void main1(String[] args){
        Scanner sc=new Scanner(System.in);
        System.out.println("输入俩整数，求俩数和：");
        int num1=sc.nextInt();
        int num2=sc.nextInt();
        System.out.println(Add(num1,num2));
        System.out.println("输入三小数，求三数和：");
        double num3=sc.nextDouble();
        double num4=sc.nextDouble();
        double num5=sc.nextDouble();
        System.out.println(Add(num3,num4,num5));
    }*/

    public static int targer(int n){
        if(n==1){
            return 1;
        }
        else if(n==2){
            return 2;
        }
        else{
            return targer(n-1)+targer(n-2);
        }
    }

    public static void main2(String[] args){          //青蛙跳台阶问题
        Scanner sc=new Scanner(System.in);
        System.out.println("青蛙从第几阶开始跳：");
        int num=sc.nextInt();
        System.out.println("青蛙有"+targer(num)+"种方法跳台阶");
    }

    public static void hannuota(int n, String a, String b, String c) {
        //最后一次将1模块这样移动
        if (n == 1) {
            System.out.println("将1模块从" + a + "移至" + c + "处");
        } else {
            //将第1至n-1模块从A塔移至工具塔（B塔）
            hannuota(n - 1, a, c, b);
            //1至n-1挪动完后，将第n个模块从A塔移至“C塔”
            System.out.println("将" + n + "模块从" + a + "移至" + c + "处");
            //将第n个模块移动完后将剩下的n-1个模块从B塔移动至C塔
            hannuota(n - 1, b, a, c);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //输入要处理的模块数
        int n = sc.nextInt();
        //假设初始所有模块在A塔，要移动至C塔
        hannuota(n, "A塔", "B塔", "C塔");
        //计算汉诺塔最少移动次数
        double ret = Math.pow(2, n) - 1;
        System.out.println("至少要移动" + ret + "次");
    }

}
